package com.rede.didiok.rank.restapi;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.rede.didiok.common.annotion.log.BussinessLog;
import com.rede.didiok.common.constant.conf.SysConf;
import com.rede.didiok.common.enums.BehaviorEnum;
import com.rede.didiok.common.utils.ResultUtil;
import com.rede.didiok.common.utils.StringUtils;
import com.rede.didiok.rank.service.MemberGradeService;
import com.rede.didiok.rank.service.RankMemberService;

/**
 * 标签RestApi
 *
 * @author Rede
 * @date 2023年10月26日12:03:17
 */
@RestController
@RequestMapping("/memberGrade")
@Api(value = "榜单成员等级相关接口", tags = {"榜单成员等级相关接口"})
@Slf4j
public class MemberGradeRestApi {

    @Autowired
    private RankMemberService rankMemberService;
    @Autowired
    private MemberGradeService memberGradeService;

    /**
     * 获取榜单成员等级的信息
     *
     * @return
     */
    @ApiOperation(value = "获取成员等级的信息", notes = "获取成员等级的信息")
//    @GetMapping("/getTagList")
    @GetMapping("/getGradeList")
    public String getGradeList() {
        log.info("获取成员等级信息");
        return ResultUtil.result(SysConf.SUCCESS, memberGradeService.getList());
    }

    /**
     * 通过 gradeUid 获取文章
     *
     * @param currentPage
     * @param pageSize
     * @return
     */
    @BussinessLog(value = "点击成员等级", behavior = BehaviorEnum.VISIT_GRADE)
    @ApiOperation(value = "通过gradeUid获取榜单成员", notes = "通过gradeUid获取榜单成员")
    @GetMapping("/getRankMembersByGradeUid")
//    @GetMapping("/getArticleByTagUid")
    public String getRankMembersByGradeUid(@ApiParam(name = "gradeUid", value = "成员等级UID", required = false) @RequestParam(name = "gradeUid", required = false) String gradeUid,
                                     @ApiParam(name = "currentPage", value = "当前页数", required = false) @RequestParam(name = "currentPage", required = false, defaultValue = "1") Long currentPage,
                                     @ApiParam(name = "pageSize", value = "每页显示数目", required = false) @RequestParam(name = "pageSize", required = false, defaultValue = "10") Long pageSize) {

        if (StringUtils.isEmpty(gradeUid)) {
            return ResultUtil.errorWithMessage("传入TagUid不能为空");
        }
        log.info("通过gradeUid获取榜单成员列表");
        return ResultUtil.result(SysConf.SUCCESS, rankMemberService.searchRankMemberByGrade(gradeUid, currentPage, pageSize));
    }

}

